home *** CD-ROM | disk | FTP | other *** search
/ Aminet 50 / Aminet 50 (2002)(GTI - Schatztruhe)[!][Aug 2002].iso / Aminet / dev / mui / MCC_SpeedBar.lha / MCC_SpeedBar / Developer / C / Examples / demo1.c next >
C/C++ Source or Header  |  2002-06-13  |  5KB  |  152 lines

  1.  
  2. #include <proto/exec.h>
  3. #include <proto/dos.h>
  4. #include <proto/muimaster.h>
  5. #include <clib/alib_protos.h>
  6. #include <mui/SpeedBar_mcc.h>
  7. #include <mui/SpeedBarCfg_mcc.h>
  8. #include <string.h>
  9. #include <stdio.h>
  10.  
  11. /***********************************************************************/
  12.  
  13. long __stack = 8192;
  14. struct Library *MUIMasterBase;
  15.  
  16. /***********************************************************************/
  17.  
  18. #ifndef MAKE_ID
  19. #define MAKE_ID(a,b,c,d) ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
  20. #endif
  21.  
  22. /***********************************************************************/
  23.  
  24. struct MUIS_SpeedBar_Button buttons[] =
  25. {
  26.     {0, "_Get", "Get the disc.", 0, NULL},
  27.     {1, "Sa_ve", "Save the disc.", 0, NULL},
  28.     {2, "_Stop", "Stop the connection.", 0, NULL},
  29.     {MUIV_SpeedBar_Spacer},
  30.     {3, "_Disc", "Disc page.", 0, NULL},
  31.     {4, "_Matches", "Matches page.", 0, NULL},
  32.     {5, "_Edit", "Edit page.", 0, NULL},
  33.     {MUIV_SpeedBar_End},
  34. };
  35.  
  36. STRPTR pics[] =
  37. {
  38.     "Get",
  39.     "Save",
  40.     "Stop",
  41.     "Disc",
  42.     "Matches",
  43.     "Edit",
  44.     NULL
  45. };
  46.  
  47. /***********************************************************************/
  48.  
  49. int
  50. main(int argc,char **argv)
  51. {
  52.     int res;
  53.  
  54.     if (MUIMasterBase = OpenLibrary("muimaster.library",19))
  55.     {
  56.         Object                          *app, *win, *sb;
  57.         Object                          *cfg, *update;
  58.         struct MUIS_SpeedBarCfg_Config  c = {MUIV_SpeedBar_ViewMode_TextGfx,MUIV_SpeedBarCfg_Borderless|MUIV_SpeedBarCfg_Sunny};
  59.  
  60.         if (app = ApplicationObject,
  61.                 MUIA_Application_Title,         "SpeedBar Demo1",
  62.                 MUIA_Application_Version,       "$VER: SpeedBarDemo1 14.4 (13.6.2002)",
  63.                 MUIA_Application_Copyright,     "Copyright 1999-2002 by Alfonso Ranieri",
  64.                 MUIA_Application_Author,        "Alfonso Ranieri <alforan@tin.it>",
  65.                 MUIA_Application_Description,   "Speed(Bar|Button|BarCfg).mcc test",
  66.                 MUIA_Application_Base,          "SPEEDBARTEST",
  67.                 SubWindow, win = WindowObject,
  68.                     MUIA_Window_ID,             MAKE_ID('M','A','I','N'),
  69.                     MUIA_Window_Title,          "SpeedBar Demo1",
  70.                     WindowContents, VGroup,
  71.                         Child, HGroup,
  72.                             GroupFrame,
  73.                             Child, sb = SpeedBarObject,
  74.                                 MUIA_Group_Horiz,               TRUE,
  75.                                 MUIA_SpeedBar_Borderless,       TRUE,
  76.                                 MUIA_SpeedBar_Sunny,            TRUE,
  77.                                 MUIA_SpeedBar_Buttons,          buttons,
  78.                                 MUIA_SpeedBar_StripUnderscore,  TRUE,
  79.                                 MUIA_SpeedBar_EnableUnderscore, TRUE,
  80.                                 MUIA_SpeedBar_BarSpacer,        TRUE,
  81.                                 MUIA_SpeedBar_PicsDrawer,       "PROGDIR:PICS",
  82.                                 MUIA_SpeedBar_Pics,             pics,
  83.                             End,
  84.                             Child, HSpace(0),
  85.                         End,
  86.                         Child, VSpace(0),
  87.                         Child, VGroup,
  88.                             GroupFrameT("Appareance"),
  89.                             Child, cfg = SpeedBarCfgObject,
  90.                                 MUIA_SpeedBarCfg_Config, &c,
  91.                             End,
  92.                             Child, VSpace(0),
  93.                             Child, update = MUI_MakeObject(MUIO_Button,"_Update"),
  94.                         End,
  95.                         Child, VSpace(0),
  96.                     End,
  97.                 End,
  98.             End)
  99.         {
  100.             ULONG sigs = 0, id;
  101.  
  102.             DoMethod(win,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,MUIV_Notify_Application,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  103.             DoMethod(update,MUIM_Notify,MUIA_Pressed,FALSE,app,2,MUIM_Application_ReturnID,TAG_USER);
  104.  
  105.             set(win,MUIA_Window_Open,TRUE);
  106.  
  107.             while ((id = DoMethod(app,MUIM_Application_NewInput,&sigs))!=MUIV_Application_ReturnID_Quit)
  108.             {
  109.                 if (id==TAG_USER)
  110.                 {
  111.                     struct MUIS_SpeedBarCfg_Config *c;
  112.  
  113.                     get(cfg,MUIA_SpeedBarCfg_Config,&c);
  114.  
  115.                     SetAttrs(sb,MUIA_SpeedBar_ViewMode,c->ViewMode,
  116.                                 MUIA_SpeedBar_Borderless,c->Flags & MUIV_SpeedBarCfg_Borderless,
  117.                                 MUIA_SpeedBar_RaisingFrame,c->Flags & MUIV_SpeedBarCfg_Raising,
  118.                                 MUIA_SpeedBar_SmallImages,c->Flags & MUIV_SpeedBarCfg_SmallButtons,
  119.                                 MUIA_SpeedBar_Sunny,c->Flags & MUIV_SpeedBarCfg_Sunny,
  120.                                 TAG_DONE);
  121.                 }
  122.  
  123.                 if (sigs)
  124.                 {
  125.                     sigs = Wait(sigs | SIGBREAKF_CTRL_C);
  126.                     if (sigs & SIGBREAKF_CTRL_C) break;
  127.                 }
  128.             }
  129.  
  130.             MUI_DisposeObject(app);
  131.  
  132.             res = RETURN_OK;
  133.         }
  134.         else
  135.         {
  136.             printf("%s: can't create application\n",argv[0]);
  137.             res = RETURN_FAIL;
  138.         }
  139.  
  140.         CloseLibrary(MUIMasterBase);
  141.     }
  142.     else
  143.     {
  144.         printf("%s: Can't open muimaster.library ver 19 or higher\n",argv[0]);
  145.         res = RETURN_ERROR;
  146.     }
  147.  
  148.     return res;
  149. }
  150.  
  151. /***********************************************************************/
  152.